package com.demo.morning;

/**
 * @ClassName Clone练习
 * @Description TODO
 * @Author tianqinglong
 * @Date 10:06 2022/7/7
 * @Version 1.0
 **/
public class Clone练习 {
    public static void main(String[] args) throws CloneNotSupportedException {
        A a = new A();
        a.x=100;
        A a2=a;
        System.out.println(a2.x);
        System.out.println(a.x);
        A a3= (A) a.clone();
        a.x=500;
        System.out.println(a3.x);
        System.out.println(a.x);
    }
}
class A implements Cloneable{
    int x=0;

    public void setX(int x) {
        this.x = x;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
